import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
        public static void main(String[] args) {
            //优先级队列在offer录入后默认为小根堆
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        priorityQueue.offer(11);
        priorityQueue.offer(15);
        priorityQueue.offer(18);
        priorityQueue.offer(31);
        priorityQueue.offer(7);


            System.out.println(priorityQueue.poll());
            System.out.println(priorityQueue.poll());
            System.out.println(priorityQueue.poll());
            System.out.println(priorityQueue.poll());
            System.out.println(priorityQueue.poll());


        int[] array = {11,15,8,31,7};
        TestHeap testHeap = new TestHeap();
        int[] ret = testHeap.smallestK(array,3);
        int[] tmp = testHeap.biggestK(array,3);
        System.out.println(Arrays.toString(ret));
        System.out.println(Arrays.toString(tmp));

//

        }

        public static void main1(String[] args) {
            TestHeap testHeap = new TestHeap();
            int[] array = {27, 15, 19, 18, 28, 34, 65, 49, 25, 37};
            testHeap.initHeap(array);
            testHeap.createHeap();
            System.out.println("=======");
            testHeap.offer(80);
            System.out.println("===========");
        }
}